package com.gw.smscheck.controller.business.alarm;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.gw.smscheck.entity.business.alarm.AlarmLog;
import com.gw.smscheck.service.business.alarm.AlarmLogService;
import com.gw.smscheck.util.ResultConversion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@Api(description="【大屏告警类型分布】")
@Controller
@RequestMapping("/alarmStatisticsController")
public class AlarmStatisticsController {

    @Autowired
    private AlarmLogService alarmLogService;
    /**
     * 查询地图告警类型分布
     *
     * @return
     */
    @RequestMapping(value = "/findMapAlarmType", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="查询所有告警类型", notes="查询所有告警类型分布")
    public String findMapAlarmType() {

        List<AlarmLog> list = alarmLogService.findMapAlarmType();

        for(int i = 0;i < list.size();i ++){
            list.get(i).getIndex();
            list.get(i).getAlarmName();
            list.get(i).setAlarmName( list.get(i).getAlarmName()+list.get(i).getIndex());
        }

        return JSON.toJSONString(list);

    }
    /**
     * 根据告警类型查询
     *
     * @return
     */
    @RequestMapping(value = "/findByType", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="根据告警类型查询", notes="根据告警类型查询")
    public String findByType(AlarmLog alarmLog) {

        PageInfo<AlarmLog> pageInfo = alarmLogService.findByType(alarmLog);
        return ResultConversion.ToEasyUIDataGrid(pageInfo).toJSONString();

    }
    /**
     * 在辖区占比查询
     *
     * @return
     */
    @RequestMapping(value = "/jurisdictionProportion", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="在辖区占比查询", notes="在辖区占比查询")
    public String jurisdictionProportion() {
        List<AlarmLog> list = alarmLogService.jurisdictionProportion();
        return JSON.toJSONString(list);
    }
}
